package com.example.ormlitedemo;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.example.ormlitedemo.Pojo.UserInfo;

import java.util.List;

public class MainActivity extends AppCompatActivity {
private Button btn,del;
private UserDao userDao;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        btn = findViewById(R.id.btn);
        del = findViewById(R.id.btn1);
        userDao = new UserDao(MainActivity.this);
        UserInfo userInfo = new UserInfo();
        userInfo.setAddr("地址");
        userInfo.setName("名字");
        userInfo.setSex("性别");
        userDao.create(userInfo);
        UserInfo userInfo1 = new UserInfo();
        userInfo1.setAddr("地址1");
        userInfo1.setName("名字1");
        userInfo1.setSex("性别2");
        userDao.insert(userInfo1);
        btn.setOnClickListener(v ->creatobj() );
        del.setOnClickListener(v -> clear());
    }
    private void  creatobj(){
        List<UserInfo> select = userDao.select();
        Log.i("TAG", "creatobj: "+select.toString());
    }
    private void clear(){
        userDao.clear();
    }
}